let userinof = JSON.parse(localStorage.getItem('userinof'))//取出本地存储

let username = userinof == null ? '' : userinof.username
let menus = userinof == null ? [] : userinof.menus
let menus_url = userinof == null ? [] : userinof.menus_url
let list = userinof == null ? {} : userinof

export default {
    state: {
        username,
        menus,
        menus_url,
        list
    },

    mutations: {
        USERNAME(state, data) {
            state.username = data
        },
        MENUS(state, data) {
            state.menus = data
        },
        MENUSURL(state, data) {
            state.menus_url = data
        },
        SETLIST(state, data) {
            state.list = data
        },
    },
    actions: {
        quit({ commit }) {
            commit('USERNAME', '')
            commit('MENUS', [])
            commit('MENUSURL', [])
            commit('SETLIST', {})
            localStorage.removeItem('userinof')
        }
    }
}